<?php

class Application_Model_Box
{
	protected $_id;
	protected $_longitude;
	protected $_latitude;
	protected $_online;
	protected $_error_code;
	protected $_areaid;
	
	public function __construct(array $options = null)
	{
		if (is_array($options)) {
			$this->setOptions($options);
		}
	}
	
	public function __set($name, $value)
	{
		$method = 'set' . $name;
		if (('mapper' == $name) || !method_exists($this, $method)) {
			throw new Exception('Invalid user property');
		}
		$this->$method($value);
	}
	
	public function __get($name)
	{
		$method = 'get' . $name;
		if (('mapper' == $name) || !method_exists($this, $method)) {
			throw new Exception('Invalid user property');
		}
		return $this->$method();
	}
	
	public function setOptions(array $options)
	{
		$methods = get_class_methods($this);
		foreach ($options as $key => $value) {
			$method = 'set' . ucfirst($key);
			if (in_array($method, $methods)) {
				$this->$method($value);
			}
		}
		return $this;
	}
	
	public function setId($id){
		$this->_id = $id;
		return $this;
	}
	
	public function getId(){
		return $this->_id;
	}
	
	public function setLongitude($longitude){
		$this->_longitude = $longitude;
		return $this;
	}
	
	public function getLongitude(){
		return $this->_longitude;
	}
	
	public function setLatitude($latitude){
		$this->_latitude = $latitude;
		return $this;
	}
	
	public function getLatitude(){
		return $this->_latitude;
	}
	
	public function setOnline($online){
		$this->_online = (boolean) $online;
		return $this;
	}
	
	public function getOnline(){
		return $this->_online;
	}
	
	public function setErrorCode($error_code){
		$this->_error_code = $error_code;
		return $this;
	}
	
	public function getErrorCode(){
		return $this->_error_code;
	}
	
	public function setAreaId($areaid){
		$this->_areaid = $areaid;
		return $this;
	}
	
	public function getAreaId(){
		return $this->_areaid;
	}


}

